//
//  UserAccountTool.swift
//  sxwb
//
//  Created by TianDu on 2016/11/17.
//  Copyright © 2016年 TianDu. All rights reserved.
//

import UIKit

class UserAccountTool {
    
    var account : UserAccount?
    
    
    /// 计算属性
    var filePath : String{
        
        let docuPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
        return docuPath + "/account.plist"
    }
    
    
    /// 计算属性
    var isLogin : Bool{
        
        if account == nil {
            return false
        }
        
        if account?.expires_date == nil {
            return false
        }
        
        return account?.expires_date?.compare(Date()) == ComparisonResult.orderedDescending
    }
    
    
    init() {
        
        account = NSKeyedUnarchiver.unarchiveObject(withFile: filePath) as? UserAccount
    }
    
}
